#include "daydata.h"

DayData::DayData(QWidget *parent) : QWidget(parent)
{
    this->setMinimumSize(800,480);
    this->setMaximumSize(800,480);
}


void DayData::setVal(int x, int y,QString wicon)
{
    QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间

    weekday = new ShowLabel(this);
    weekday->addFontSize(2);
    //weekday->setGeometry(QRect(250, 80, 100, 40));
    weekday->setGeometry(QRect(x, y, 80, 40));
    weekday->setAlignment(Qt::AlignHCenter);
    weekday->setText(tr("今天"));

    date = new ShowLabel(this);
    date->addFontSize(2);
    date->setGeometry(QRect(x, y+40, 80, 40));
    date->setAlignment(Qt::AlignHCenter);
    date->setText(time.toString("M月d日"));


    weatherIcon = new QLabel(this);
    weatherIcon->setGeometry(QRect(x+10, y+90, 70, 70));
    QString iconStr = ":/images/weathercn02/" + wicon + ".png" ;
    weatherIcon->setPixmap(QPixmap(iconStr));
    weatherIcon->setScaledContents(true);

    temp = new ShowLabel(this);
    temp->addFontSize(3);
    temp->setGeometry(QRect(x, y+180, 80, 40));
    temp->setAlignment(Qt::AlignHCenter);
    temp->setText(tr("２-９℃"));


    weather = new ShowLabel(this);
    weather->addFontSize(3);
    weather->setGeometry(QRect(x, y+230, 80, 40));
    weather->setAlignment(Qt::AlignHCenter);
    weather->setText(tr("晴"));

    wind = new ShowLabel(this);
    wind->addFontSize(-2);
    wind->setGeometry(QRect(x, y+290, 80, 40));
    wind->setAlignment(Qt::AlignHCenter);
    wind->setText(tr("风"));


    windpower = new ShowLabel(this);
    windpower->addFontSize(0);
    windpower->setGeometry(QRect(x, y+320, 80, 40));
    windpower->setAlignment(Qt::AlignHCenter);
    windpower->setText(tr("3级"));
}


void DayData::updateVal(QString *daily)
{
    weekday->setText(daily[1]);
    date->setText(daily[0].mid(5));
    QString iconStr = ":/images/weathercn02/" + daily[5] + ".png" ;
    weatherIcon->setPixmap(QPixmap(iconStr));
    temp->setText(daily[2]+tr("-")+daily[3]+tr("℃"));
    weather->setText(daily[4]);
    wind->setText(daily[6]);
    windpower->setText(daily[7]);
}
